package com.designPattern.simpleFactory.factory;

import com.designPattern.simpleFactory.product.Pizza;
import com.designPattern.simpleFactory.productImpl.CheesePizza;
import com.designPattern.simpleFactory.productImpl.ClamPizza;
import com.designPattern.simpleFactory.productImpl.PepperonPizza;
import com.designPattern.simpleFactory.productImpl.VeggiePizza;

/**
 * 简单工厂
 */
public class SimplePizzaFactory {
	
	/**
	 * 根据披萨类型创建披萨对象的方法
	 * @param type
	 * @return Pizza
	 */
	public Pizza createPizza(String type){
		Pizza pizza = null;
		
		if(type != null){
			if("cheese".equals(type)){
				pizza = new CheesePizza();
			}else if("clam".equals(type)){
				pizza = new ClamPizza();
			}else if("veggie".equals(type)){
				pizza = new VeggiePizza();
			}else if("pepperon".equals(type)){
				pizza = new PepperonPizza();
			}
		}
		
		return pizza;
	}
	
}
